import Vue from 'vue'
import Vuex from 'vuex'
import {nanoid} from 'nanoid'
import axios from'axios'
Vue.use(Vuex)
const actios = {

}
const mutations = {
    ADD_LIST(state){
        axios.get('https://v1.hitokoto.cn/?c=b&c=a').then(
            response =>{
                state.SayingList.unshift({id:nanoid(),title:response.data.hitokoto})
            },
            error =>{
                alert('请求以失败',error)
            }
        )
    },
    INCREMENT_ADD_AGE(state,value){
            state.School.age += value
    }
}
const state = {
    School: {
        name: '尚硅谷',
        address: '洪福科技园',
        tel:'123456',
        age:8
    },
    SayingList:[]
}
const getters = {
    bigAge(){
        return state.School.age *10
    }
}
export default new Vuex.Store({
    actios,
    mutations,
    state,
    getters
})